/*
   Copyright 2009 Abdulla Abdurakhmanov (abdulla@latestbit.com)
   Original sources are available at www.latestbit.com

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
*/

package org.latestbit.smartobjects.network;

/**
 * Interface describes all connection control events for managed connections
 * @author abdulla-a
 */
public interface IManagedConnectionListener {
	
	/**
	 * Event occurs when managed connection has been connected (available to send data) to endpoint 
	 * @param mconnection managed connection
	 */
	public void onConnected(IManagedConnection mconnection);
	
	/**
	 * Event occurs when network connection handler has been connected
	 * @param handler connection handler
	 */
	public void onConnected(ConnectionHandler handler);

	/**
	 * Event occurs when managed connection has been disconnected from endpoint
	 * @param mconnection managed connection
	 */	
	public void onDisconnected(IManagedConnection mconnection);
	
	/**
	 * Event occurs when network connection handler has been disconnected
	 * @param handler connection handler
	 */
	public void onDisconnected(ConnectionHandler handler);	

	/**
	 * Event occurs when managed connection trying to connect failed
	 * @param mconnection managed connection
	 * @param errorMessage error details
	 */
	public void onConnectionFailure(IManagedConnection mconnection, String errorMessage);
	
	/**
	 * Event occurs when network connection handler trying to connect failed
	 * @param handler connection handler
	 * @param errorMessage error details
	 */
	public void onConnectionFailure(ConnectionHandler handler, String errorMessage);
	
}
